package com.by.controller;

import com.by.common.dao.bean.PageResult;
import com.by.common.token.TokenTemplate;
import com.by.core.bean.ResultBean;
import com.by.core.controller.BaseController;
import com.by.entity.User;
import com.by.query.UserQuery;
import com.by.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.web.bind.annotation.*;

/**
 * @author ServivE
 * @version 0.1
 * @className UserController
 * @description
 * @date 2024/11/7 10:07
 * @since jdk17
 */
@RestController
@RequestMapping("/api/sys")
@Api(tags = {"用户管理"})
public class UserController extends BaseController {


    @Autowired
    UserService userService;
    @Autowired(required = false)
    TokenTemplate tokenTemplate;

    @ApiOperation(value="保存用户")
    @PostMapping("/user")
    public ResultBean save(@RequestBody User user) {
        int rs = userService.saveEntity(user);
        return saveResult(rs);
    }

    @GetMapping("/user")
    @ApiOperation(value="查询用户")
    public ResultBean<PageResult> query(UserQuery query) {
        PageResult<User> result = userService.query(query);
        return success("用户列表", result);
    }
}
